package com.cdream.basic.mq.kafka;

import cn.hutool.core.collection.CollUtil;
import org.apache.kafka.clients.admin.*;

import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ExecutionException;

/**
 * @author cdream
 * @date 2022/10/29
 */
public class KafkaAdminClientDemo {
    private static final String BROKER_LIST = "192.168.0.118:9092";
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        Properties properties = new Properties();
        properties.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG,BROKER_LIST);
        properties.put(AdminClientConfig.REQUEST_TIMEOUT_MS_CONFIG,30000);
        AdminClient client = KafkaAdminClient.create(properties);
        DescribeTopicsResult mytopic = client.describeTopics(CollUtil.newArrayList("mytopic"));
        Map<String, TopicDescription> map = mytopic.all().get();
        System.out.println(map);
        client.close();
    }
}
